/**
  *************************(C) COPYRIGHT 2022 LionHeart*************************
  * @file       recue_IDcard_task.h
  * @brief      救援卡片的兑换
  * @note       
  * @history
  *  Version    Date            Author          Modification
  *  V1.0.0     2022/3/27       yanfubing       1. done
  @verbatim
  ==============================================================================
  ==============================================================================
  @endverbatim
  *************************(C) COPYRIGHT 2022 LionHeart*************************
  */

#ifndef RESCUE_ID_CARD_TASK_H
#define RESCUE_ID_CARD_TASK_H
#include "bsp_can.h"
#include "CAN_receive.h"
#include "remote_control.h"
#include "main.h"
#include "pid.h"
#include "user_lib.h"

#define CARD_ADD_MILEAGE    1   //救援卡增加的长度

#define ID_Card_max_mileage    2500
//电机的RMP转换为角度
#define MOTOR_ECD_TO_ANGLE    1/800
//只按键的最大速度
#define rescue_IDcard_task_MAX_SPEED 300
//救援卡电机延时
#define rescue_IDcard_task_INIT_TIME 150
//救援卡任务一阶滤波系数
#define rescue_IDcard_task_CONTROL_TIME 0.002f 
/**************救援卡电机，速度,里程闭环PID M2006************/

#define M2006_rescue_IDcard_MILEAGE_PID_KP 7.0f
#define M2006_rescue_IDcard_MILEAGE_PID_KI 0.1f
#define M2006_rescue_IDcard_MILEAGE_PID_KD 0.5f
#define M2006_rescue_IDcard_MILEAGE_PID_MAX_OUT  3000.0f
#define M2006_rescue_IDcard_MILEAGE_PID_MAX_IOUT 10.0f

#define M2006_rescue_IDcard_SPEED_PID_KP 7.0f
#define M2006_rescue_IDcard_SPEED_PID_KI 0.1f
#define M2006_rescue_IDcard_SPEED_PID_KD 0.5f
#define M2006_rescue_IDcard_SPEED_PID_MAX_OUT  1000.0f
#define M2006_rescue_IDcard_SPEED_PID_MAX_IOUT 10.0f

#define engineering_Clamp_turn_NUM  0.167f

typedef enum
{
  CLOSE=0,
  OPEN =1,
}rescue_IDcard_state_e;


typedef struct 
{
const motor_measure_t *rescue_IDcard_motor_measure;
	fp32 angle;
	fp32 speed_set;
  fp32 mileage_set;
	int16_t give_current;
}rescue_IDcard_motor_t;


typedef struct 
{               
	const can2_receive_t *rescue_IDcard_can_rc;
	rescue_IDcard_state_e rescue_IDcard_state;            //救援卡状态机
	
	rescue_IDcard_motor_t rescue_IDcard_motor_data[1];  //救援m2006电机一个

	pid_type_def  rescue_IDcard_motor_mileage_pid[1]; 
	pid_type_def  rescue_IDcard_motor_pid[1];     
	                                          //使用一阶低通滤波减缓设定值
	first_order_filter_type_t engineering_cmd_rescue_IDcard;   
	fp32 rescue_IDcard_task_max_speed;          //升降电机最大速度     
	 
}rescue_IDcard_control_t;

extern rescue_IDcard_control_t rescue_IDcard_control;

/**
	* @brief           救援卡任务
	* @param[in]      pvParameters: 空
	* @retval         none
	*/
extern void rescue_IDcard_task(void const* pvParameters);


#endif


